package com.lsl.prototype_pattern;

import java.util.HashMap;

/**
 * 使用Product接口来复制实例
 * 使用者 Client
 *
 * @author Zed
 * @description
 * @date 2022/11/27 11:38
 */
public class Manager {
    //保存实例的名字和实例之间的对应关系
    private HashMap showcase = new HashMap<>(16);

    public void register(String name, Product proto) {
        showcase.put(name, proto);
    }

    public Product create(String protoName) {
        Product product = (Product) showcase.get(protoName);
        return product.createClone();
    }
}
